From 8665aa44c30b96457828d310f0140cd0987d78f1 Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Sat, 12 May 2007 16:24:50 +0100 Subject: [PATCH] hvm: Fix ACPI shutdown, broken by my previous changeset. It turns out that although PIIX4 hardware defines the S5 type code to be 000, all OSes will discover the correct code by evlauating an \_Sx object in the ACPI DSDT. And we set the type code in that object to be 111. So this patch keeps the other cleanups made to the piix4acpi.c file, but switches back to checking for code 111. It also makes it clearer in both the ioemu code and in the dsdt source code where these magic numbers come from. Let's hope noone actually has the true PIIX4 type codes hardcoded (it's highly doubtful that anyone would). Signed-off-by: Keir Fraser --- tools/firmware/hvmloader/acpi/dsdt.asl | 10 +++++----- tools/firmware/hvmloader/acpi/dsdt.c | 4 ++-- tools/ioemu/hw/piix4acpi.c | 24 ++++++++++++++---------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/tools/firmware/hvmloader/acpi/dsdt.asl b/tools/firmware/hvmloader/acpi/dsdt.asl index 0c843c1833..1f0a83960c 100644 --- a/tools/firmware/hvmloader/acpi/dsdt.asl +++ b/tools/firmware/hvmloader/acpi/dsdt.asl @@ -27,13 +27,13 @@ DefinitionBlock ("DSDT.aml", "DSDT", 2, "Xen", "HVM", 0) Name (\APCL, 0x00010000) Name (\PUID, 0x00) - /* Poweroff support - ties in with qemu emulation */ + /* S5 (power-off) type codes: must match with piix4 emulation! */ Name (\_S5, Package (0x04) { - 0x07, - 0x07, - 0x00, - 0x00 + 0x07, /* PM1a_CNT.SLP_TYP */ + 0x07, /* PM1b_CNT.SLP_TYP */ + 0x00, /* reserved */ + 0x00 /* reserved */ }) Name(PICD, 0) diff --git a/tools/firmware/hvmloader/acpi/dsdt.c b/tools/firmware/hvmloader/acpi/dsdt.c index d757ed107c..eb8d1da867 100644 --- a/tools/firmware/hvmloader/acpi/dsdt.c +++ b/tools/firmware/hvmloader/acpi/dsdt.c @@ -1,11 +1,11 @@ /* * * Intel ACPI Component Architecture - * ASL Optimizing Compiler version 20060707 [Feb 16 2007] + * ASL Optimizing Compiler version 20060707 [Dec 30 2006] * Copyright (C) 2000 - 2006 Intel Corporation * Supports ACPI Specification Revision 3.0a * - * Compilation of "dsdt.asl" - Mon Feb 26 11:09:49 2007 + * Compilation of "dsdt.asl" - Sat May 12 16:13:55 2007 * * C source code output * diff --git a/tools/ioemu/hw/piix4acpi.c b/tools/ioemu/hw/piix4acpi.c index fcaadbf437..e232e82035 100644 --- a/tools/ioemu/hw/piix4acpi.c +++ b/tools/ioemu/hw/piix4acpi.c @@ -25,11 +25,15 @@ #include "vl.h" -/* PMCNTRL */ +/* PM1a_CNT bits, as defined in the ACPI specification. */ #define SCI_EN (1 << 0) #define GBL_RLS (1 << 2) -#define SUS_TYP (7 << 10) -#define SUS_EN (1 << 13) +#define SLP_TYP_Sx (7 << 10) +#define SLP_EN (1 << 13) + +/* Sleep state type codes as defined by the \_Sx objects in the DSDT. */ +/* These must be kept in sync with the DSDT (hvmloader/acpi/dsdt.asl) */ +#define SLP_TYP_S5 (7 << 10) typedef struct AcpiDeviceState AcpiDeviceState; AcpiDeviceState *acpi_device_table; @@ -69,7 +73,7 @@ static uint32_t acpiPm1Control_readb(void *opaque, uint32_t addr) { PCIAcpiState *s = opaque; /* Mask out the write-only bits */ - return (uint8_t)(s->pm1_control & ~(GBL_RLS|SUS_EN)); + return (uint8_t)(s->pm1_control & ~(GBL_RLS|SLP_EN)); } static void acpiPm1ControlP1_writeb(void *opaque, uint32_t addr, uint32_t val) @@ -77,10 +81,10 @@ static void acpiPm1ControlP1_writeb(void *opaque, uint32_t addr, uint32_t val) PCIAcpiState *s = opaque; val <<= 8; - s->pm1_control = ((s->pm1_control & 0xff) | val) & ~SUS_EN; + s->pm1_control = ((s->pm1_control & 0xff) | val) & ~SLP_EN; /* Check for power off request. */ - if ((val & (SUS_EN|SUS_TYP)) == SUS_EN) + if ((val & (SLP_EN|SLP_TYP_Sx)) == (SLP_EN|SLP_TYP_S5)) qemu_system_shutdown_request(); } @@ -88,17 +92,17 @@ static uint32_t acpiPm1ControlP1_readb(void *opaque, uint32_t addr) { PCIAcpiState *s = opaque; /* Mask out the write-only bits */ - return (uint8_t)((s->pm1_control & ~(GBL_RLS|SUS_EN)) >> 8); + return (uint8_t)((s->pm1_control & ~(GBL_RLS|SLP_EN)) >> 8); } static void acpiPm1Control_writew(void *opaque, uint32_t addr, uint32_t val) { PCIAcpiState *s = opaque; - s->pm1_control = val & ~SUS_EN; + s->pm1_control = val & ~SLP_EN; /* Check for power off request. */ - if ((val & (SUS_EN|SUS_TYP)) == SUS_EN) + if ((val & (SLP_EN|SLP_TYP_Sx)) == (SLP_EN|SLP_TYP_S5)) qemu_system_shutdown_request(); } @@ -106,7 +110,7 @@ static uint32_t acpiPm1Control_readw(void *opaque, uint32_t addr) { PCIAcpiState *s = opaque; /* Mask out the write-only bits */ - return (s->pm1_control & ~(GBL_RLS|SUS_EN)); + return (s->pm1_control & ~(GBL_RLS|SLP_EN)); } static void acpi_map(PCIDevice *pci_dev, int region_num, -- 2.30.2